﻿using Sustainalytics.ClientDW.DataAccessLayer;
using Sustainalytics.ClientDW.Entities;
using System;
using System.Collections.Generic;

namespace Sustainalytics.GCCS
{
    public class GCPrincipleSummaryManager : IGCPrincipleSummaryManager
    {
        private readonly IClientDWGlobalCompactRepository _gccRepo;


        public GCPrincipleSummaryManager(IClientDWGlobalCompactRepository gccRepo)
        {
            this._gccRepo = gccRepo;
        }

        public List<GCPrincipleSummary> GetList(Guid companyId, GCAssessment? overallAssessment)
        {
            try
            {
                GCCEventSource.Log.GCPrincipleSummary_GetList(companyId);

                List<GCPrincipleSummary> lst = this._gccRepo.GetGCPrincipleSummaryList(companyId, overallAssessment);

                GCCEventSource.Log.GCPrincipleSummary_GetList_Success(companyId);

                return lst;
            }
            catch (Exception ex)
            {
                GCCEventSource.Log.GCPrincipleSummary_GetList_Error(companyId, ex);
                throw;
            }
        }

        public int GetCount(Guid companyId, GCAssessment? overallAssessment)
        {
            try
            {
                GCCEventSource.Log.GCPrincipleSummary_GetCount(companyId);

                int count = this._gccRepo.GetGCPrincipleSummaryCount(companyId, overallAssessment);

                GCCEventSource.Log.GCPrincipleSummary_GetList_Success(companyId);

                return count;
            }
            catch (Exception ex)
            {
                GCCEventSource.Log.GCPrincipleSummary_GetCount_Error(companyId, ex);
                throw;
            }
        }
    }
}
